Parse.Cloud.beforeSave('RoBacth', async (req, res) => {
  res.success()
  const bacth = req.object
  if (bacth.id) return
  const content = bacth.get('content')
  console.log('content>>>>>>', content)
  let nicknameLimit = 0
  if (content) {
    const list = content.split('\n').filter(item => item)
    let tasks = list.map(item => {
      console.log('in>>>>>>>>>', item)
      const [qq, password, nickname] = item.split('----')
      if (!nickname) {
        nicknameLimit++
      }
      return {
        qq,
        password,
        nickname,
        done: 0
      }
    })
    const nicknames = await new Parse.Query('RoNickname').notEqualTo('isUsed', true).limit(nicknameLimit).find()
    const nicknameTask = []
    tasks = tasks.map(item => {
      if (!item.nickname) {
        const nickname = nicknames.pop()
        if (nickname) {
          item.nickname = nickname.get('nickname')
          nickname.set('isUsed', true)
          nicknameTask.push(nickname)
        }
      }
      return new Parse.Object('RoTask', item)
    })
    await Parse.Object.saveAll(tasks)
    await Parse.Object.saveAll(nicknameTask)
    console.log('ok')
  }
})
